﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Events.BaseInvokableCall
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Reflection;

#nullable disable
namespace UnityEngine.Events
{
  internal abstract class BaseInvokableCall
  {
    protected BaseInvokableCall()
    {
    }

    protected BaseInvokableCall(object target, MethodInfo function)
    {
      if (function == null)
        throw new ArgumentNullException(nameof (function));
      if (function.IsStatic)
      {
        if (target != null)
          throw new ArgumentException("target must be null");
      }
      else if (target == null)
        throw new ArgumentNullException(nameof (target));
    }

    public abstract void Invoke(object[] args);

    protected static void ThrowOnInvalidArg<T>(object arg)
    {
      if (arg != null && !(arg is T))
        throw new ArgumentException(UnityString.Format("Passed argument 'args[0]' is of the wrong type. Type:{0} Expected:{1}", (object) arg.GetType(), (object) typeof (T)));
    }

    protected static bool AllowInvoke(Delegate @delegate)
    {
      object target = @delegate.Target;
      return target == null || !(target is UnityEngine.Object @object) || @object != (UnityEngine.Object) null;
    }

    public abstract bool Find(object targetObj, MethodInfo method);
  }
}
